package com.franklin.plugins.common.collection;

import java.io.Serializable;
import java.util.Comparator;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.ToLongFunction;

/**
 * @author Franklin
 * @since 2021/9/30 12:27
 */
@FunctionalInterface
public interface MyComparator<T> extends Comparator<T> {

    static <T, U extends Comparable<? super U>> Comparator<T> comparingDesc(
        Function<? super T, ? extends U> keyExtractor)
    {
        Objects.requireNonNull(keyExtractor);
        return (c1, c2) -> - keyExtractor.apply(c1).compareTo(keyExtractor.apply(c2));
    }
}
